package com.erlang.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

@Controller
//使用限定类的请求路径
@RequestMapping(value = "basic")
public class BasicController {

    /**
     * @Description 此次不限定名称则表示为默认请求方法
     */
    @RequestMapping
    public ModelAndView defaultMapping(){
        //构建对象视图对象
        ModelAndView modelAndView = new ModelAndView();
        //指定视图
        modelAndView.setViewName("succeed");
        //传递参数，接受map对象
        Map<String,Object> map = new HashMap<>();
        map.put("content", "默认");
        modelAndView.addAllObjects(map);
        return modelAndView;
    }

    /**
     * @Description 限定方法访问路径
     */
    @RequestMapping(value = "succeed")
    public ModelAndView succeed(){
        //构建对象视图对象
        ModelAndView modelAndView = new ModelAndView();
        //指定视图
        modelAndView.setViewName("succeed");
        //传递参数，接受map对象
        Map<String,Object> map = new HashMap<>();
        map.put("content", "基本");
        modelAndView.addAllObjects(map);
        return modelAndView;
    }
}